package com.fanrui.code.common.handle;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class HandlerMethod {
	
	private Object instance;
	
	private Method method;

	public HandlerMethod(Object instance, Method method) {
		super();
		this.instance = instance;
		this.method = method;
	}
	
	@Override
	public String toString() {
		return "HandlerMethod [instance=" + instance + ", method=" + method + "]";
	}

	public Object invoke(Object... args) throws InvocationTargetException {
		try {
			return this.method.invoke(this.instance, args);
		} catch (IllegalAccessException | IllegalArgumentException e) {
			throw new RuntimeException(e);
		}
	}

}
